import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import cesium from 'vite-plugin-cesium'

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());
  return {
  plugins: [vue(), cesium()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      cesium: path.resolve(__dirname, 'node_modules/cesium')
    }
  },
  server: {
    host: "0.0.0.0",
    port: 8080,
    open: true,
    proxy: {
      "/jysl": {
        target: env.VITE_JYSLAPI_BASE_URL,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/jysl/, ""),
        secure: true,
      },
    },
  },
};
});